package lib.map;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Point;

import com.dulichdanang.R;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

 public class GoogleMapOverlay extends Overlay{
	private GeoPoint p2;
	Context c;
	int img_pink;
	//Khởi tạo giá trị cho biến p2 (truyền p2 = p - biến toàn cục )
	public  GoogleMapOverlay(GeoPoint _p,Context _c,int _img_pink){
		p2 = _p;//
		c = _c;
		img_pink = _img_pink;
	}
	@Override
    public boolean draw(Canvas canvas, MapView mapView, 
    boolean shadow, long when) 
    {
        super.draw(canvas, mapView, shadow);                   
        //---translate the GeoPoint to screen pixels---
        Point screenPts = new Point();
        mapView.getProjection().toPixels(p2, screenPts);

        //---add the marker---
        Bitmap bmp = BitmapFactory.decodeResource(
           c.getResources(), img_pink);            
        canvas.drawBitmap(bmp, screenPts.x, screenPts.y-32, null);         
        return true;
    }
}
